<?php

/**
 * main actions.
 *
 * @package    TB
 * @subpackage main
 * @author     Marion Duprey
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class mainActions extends sfActions {
/**
 * Executes index action
 *
 * @param sfRequest $request A request object
 */
    public function executeIndex(sfWebRequest $request) {
	//$this->forward404Unless(isset($_POST['xml']));

	if (isset($_SERVER)) {
	    if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
	    elseif (isset($_SERVER["HTTP_CLIENT_IP"])) $ip = $_SERVER["HTTP_CLIENT_IP"];
	    else $ip = $_SERVER["REMOTE_ADDR"];
	}
	else $ip = 'WW.XX.YY.ZZ';

	$this->listener = new Listener(stripslashes($_POST['xml']), $ip);
	if ($this->listener->getReturn() == 0) {
	    $this->setLayout(false);
	    $this->getResponse()->setContentType('text/xml');
	    $this->setTemplate("error");
	}
	else {
	    $this->tu = $this->listener->getTU();

	    $this->tab_enq = $this->tu->getEnquetesDemandes();

	    $criteria = new Criteria();
	    $criteria->add(OptPeer::TU_ID, $this->tu->getId());
	    $this->tab_opt = OptPeer::doSelect($criteria);

	    $this->setLayout(false);
	    $this->getResponse()->setContentType('text/xml');
	}
    }

}